package neu.soft.service;

import neu.soft.rocketmq.InputBinding;
import neu.soft.vo.MsgBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

@Service
public class RecieveService {
    @Autowired
    InputBinding inputBinding;
    @StreamListener("input-common-1")
    public void receiveInput1(@Payload MsgBean receiveMsg)
    {
        System.out.println("input1 receive: " + receiveMsg);
    }

    @StreamListener("input-common-2")
    public void receiveInput2(@Payload MsgBean receiveMsg)
    {
        System.out.println("input2 receive: " + receiveMsg);
    }

    @StreamListener("input-common-3")
    public void receiveInput3(@Payload MsgBean receiveMsg)
    {
        System.out.println("input3 receive: " + receiveMsg);
    }

    @StreamListener("input-common-4")
    public void receiveInput4(@Payload MsgBean receiveMsg)
    {
        System.out.println("input4 receive: " + receiveMsg);
    }

    @StreamListener("input-common-5")
    public void receiveInput5(@Payload MsgBean receiveMsg)
    {
        System.out.println("input5 receive: " + receiveMsg);
    }

    //发送补货完成单给调度中心
    public boolean sendMsgForLackSupply(MsgBean msgBean){
        Message<MsgBean> message = MessageBuilder.withPayload(msgBean)
                .build();
        return inputBinding.outputCommon1().send(message);
    }

}
